<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>Chat Rooms</title>
</head>
<body>
<br>
<label for="room-name-input">你想进入什么样的聊天室?：</label>
<input id="room-name-input" type="text" size="100" placeholder="输入聊天室编号">
<input id="room-name-submit" type="button" value="确认进去">
<script>
    document.querySelector('#room-name-input').focus();
    document.querySelector('#room-name-input').onkeyup = function (e) {
        if (e.keyCode === 13) {  // enter, return
            document.querySelector('#room-name-submit').click();
        }
    };
    document.querySelector('#room-name-submit').onclick = function (e) {
        const roomName = document.querySelector('#room-name-input').value;
        window.location.pathname = roomName + '/';
    };
</script>
</body>
</html>